/*
 * CMediaSound.h
 *
 *  Created on: Sep 6, 2011
 *      Author: welcome
 */

#ifndef CMEDIASOUND_H_
#define CMEDIASOUND_H_

#include <KD/kd.h>
#include <string.h>

namespace GGEngine {

struct pcmInfo_t {
	KDuint num_channels;
	KDuint sampling_rate;
	KDuint bytes_per_sec;
	KDuint block_size;
	KDuint bits_per_sample;
	KDsize data_length;
};

// util
#define UTIL_ASSERT(e)				kdAssert(e)
#define UTIL_SAFE_DELETE(a)			{if (a){ delete a; (a)=0;}}
#define UTIL_SAFE_DELETE_ARRAY(a)	{if (a){ delete[] a; (a)=0;}}

#define MEDIA_SOUND_MIDI 1
#define MEDIA_SOUND_WAV  2
#define MEDIA_SOUND_MP3  3
#define MEDIA_SOUND_OGG  4

class CMediaSound {
public:
	CMediaSound();
	virtual ~CMediaSound();
	/*
	 * public methods
	 */
	void setMediaType(int _mediaType);
	int getMediaType();
	void attachData(char* _data, int _length);
	char* getData();
	int getDataLength();
	void setLocation(const char* _location);
	const char* getLocation();
	const pcmInfo_t* getPcmInfo();
private:
	int mediaType;
	char* data;
	int length;
	char location[256];
	struct pcmInfo_t pcmHeader;
};

} /* namespace GGEngine */
#endif /* CMEDIASOUND_H_ */
